<!doctype html>
<html>
<body>
<script>
var MyAlert = function(str){
  if(this instanceof MyAlert){
    throw new Error("MyAlert is not a constructor");
  }
  alert(str);
}
MyAlert(111);//弹出
new MyAlert(222);//报错
</script>
</body>
</html>